home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_059
/
browser
/
pf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
696b
|
44 lines
/*
Parsefile() is a modified word count from K&R page 18
M.E.S. 87-01-11
*/
#include "browser.h"
#include <stdio.h>
#include <ctype.h>
#define YES 1
#define NO 0
struct FStatistics *stats;
FILE *parsefile(fp)
FILE *fp;
{
int c,nl,nw,nc,inword;
inword = NO;
nl = nw = nc = 0;
while ((c = getc(fp)) != EOF)
{
++nc;
if ( c == '\n') ++nl;
if ( c == ' ' || c == '\n' || c == '\t') inword = NO;
else if (inword == NO)
{
inword = YES;
++nw;
}
}
stats->bites = nc;
stats->lines = nl;
stats->words = nw;
return(fp);
}